package chpt08;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class DataStreamTest {

	public static void main(String[] args) throws IOException{
		String filename = "data.bin";
		try(DataOutputStream out = new DataOutputStream(new FileOutputStream(filename))){
			out.writeUTF("测试数据");
			out.writeInt(102);
			out.writeDouble(2034.56);
			out.writeLong(123456);
			out.writeBoolean(true);	
		}
		try(DataInputStream in = new DataInputStream(new FileInputStream(filename))){
			System.out.println(in.readUTF());
			System.out.println(in.readInt());
			System.out.println(in.readDouble());
			System.out.println(in.readLong());
			System.out.println(in.readBoolean());
		}
	}
}
